<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
</head>
<style>
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    outline: 0;
    transition:  all 0.5s ease;
}
body{
    font-family: sans-serif;
}
a{
    text-decoration: none;
    color: #fff;
}
.container{
    height: 100vh;
    width: 100vw;
    display: grid;
    place-items: center;
}
.calcuator{
    position: relative;
    height: auto;
    width: auto;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 30px #000;
}

.theme-toggler{
    position: absolute;
    top: 30px;
    right: 30px;
    color: #fff;
    cursor: pointer;
    z-index: 1;
}
.theme-toggler.active{
    color: #333;
}
.theme-toggler.active::before{
    background-color: #fff;
}
.theme-toggler::before{
    content: '';
    height: 30px;
    width: 30px;
    position: absolute;
    top: 50%;
    transform: translate(-50%,-50%);
    border-radius: 50%;
    background-color:paleturquoise;
    z-index: -1;
}
#display{
    margin: 0 10px;
    height: 150px;
    width: auto;
    max-width: 270px;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    font-size: 30px;
    overflow-x: scroll;
}
#display::-webkit-scorllbar{
    display: block;
    height: 3px;
}
button{
    height: 60px;
    width: 60px;
    border: 0;
    border-radius: 30px;
    margin: 5px;
    font-size: 20px;
    cursor: pointer;
    transition: all 200ms ease;
}
button:hover{
    transform: scale(1.1);
}
button#equal{
    height: 130px;
}

.calculator.dark{
    background-color:white;
}
.calculator.dark #display{
    color: fuchsia;
}
.calculator.dark button#clear{
    background-color:orange;
}
.calculator.dark button.btn-number{
    background-color:darkcyan;
}
.calculator.dark button.btn-operator{
    background-color:forestgreen;
}
</style>
<body>
    <div class="container">
        <div class="calculator dark">
            <div class="theme-toggler active"></div>
            <div class="display-screen">
                <div id="display"></div>
            </div>
            <div class="buttons">
                <table>
                    <tr>
                        <td><button class="btn-operator" id="clear">C</button></td>
                        <td><button class="btn-operator" id="/">&divide;</button></td>
                        <td><button class="btn-operator" id="*">&times;</button></td>
                        <td><button class="btn-operator" id="backspace"></button></td>
                    </tr>
                    <tr>
                        <td><button class="btn-number" id="7">7</button></td>
                        <td><button class="btn-number" id="8">8</button></td>
                        <td><button class="btn-number" id="9">9</button></td>
                        <td><button class="btn-operator" id="-">-</button></td>
                    </tr>
                    <tr>
                        <td><button class="btn-number" id="4">4</button></td>
                        <td><button class="btn-number" id="5">5</button></td>
                        <td><button class="btn-number" id="6">6</button></td>
                        <td><button class="btn-operator" id="+">+</button></td>
                    </tr>
                    <tr>
                        <td><button class="btn-number" id="1">1</button></td>
                        <td><button class="btn-number" id="2">2</button></td>
                        <td><button class="btn-number" id="3">3</button></td>
                        <td rowspan="2"><button class="btn-equal" id="equal">=</button></td>
                    </tr>
                    <tr>
                        <td><button class="btn-operator" id="(">(</button></td>
                        <td><button class="btn-number" id="0">0</button></td>
                        <td><button class="btn-operator" id=")">)</button></td>
                    </tr>
            </table>
        </div>
    </div>
</div>
</body>
<script>
    const display = document.querySelector("#display");
    const buttons = document.querySelectorAll("button");
buttons.forEach((item) => {
   item.onclick = () =>{
    if(item.id == 'clear'){
        display.innerText= '';
    }else if(item.id == 'backspace'){
        let string = display.innerText.toString();
        display.innerText = string.substr(0,string.lenght-1); 
    }else if(display.innerText !='' && item.id =='equal'){
        display.innerText= eval(display.innerText);
    }else if(display.innerText == ''&& item.id == 'equal'){
        display.innerText='Empty!';
        setTimeout(()=>(display.innerText =''),2000);
    }else{
        display.innerText += item.id;
    }
   } 
})
     const themeToggleBtn =document.querySelector('.thmeme-toggler');
     const calculator = document.querySelector('.calculator');
     const toggleIcon = document.querySelector('.toggler-incon');
     let isDark = true;
themeToggleBtn.onclick = () => {
    calculator.classList.toggle('dark');
    themeToggleBtn.classList.toggle('active');
    isDark = !isDark;
}
</script>
</html>